import Vue from 'vue'
import VueRouter from 'vue-router'
// 导入三分字体图标样式
import '../styles/index.less'
// 加载 Vant 核心组件库
import Vant from 'vant'
// 加载 Vant 全局样式
import 'vant/lib/index.css'
// 注册使用 Vant 组件库
Vue.use(Vant)
Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
    // 这里是路由懒加载的写法
    // 完整写法是：@views/login/index.vue，但是index.vue可以省略，导入一个目录时默认导入目录下的index.vue
  },
  {
    path: '/',
   // name: 'layout', // 如果父路由有默认子路由，那他的name就没有意义，可以省略
    component: () => import('@/views/layout'),
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/home'),
      },
      {
        path: '/qa',
        name: 'qa',
        component: () => import('@/views/qa'),
      },
      {
        path: '/video',
        name: 'video',
        component: () => import('@/views/video'),
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@/views/search'),
  },
  {
    path: '/article/:articleId', //需要传递文章id
    name: 'article',
    component: () => import('@/views/article'),
     // 开启 Props 传参，说白了就是把路由参数映射到组件的 props 数据中
    props: true
  },
  {
    path: '/user/profile',
    name: 'user-profil',
    component: () => import('@/views/user-profil')
  }
]
  

const router = new VueRouter({
  routes
})

export default router
